﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using WmsApp.WindowControl;
using WmsApp.WmsService;

namespace WmsApp.Service
{
    public partial class StockTackingWrapService : IWrapService<StockTackingWrap>
    {

        public void SaveWrap(StockTackingWrap wrap)
        {
            var sc = Factory.WmsServiceFactory.GetServiceClient();
            sc.SaveStockTackingWrap(wrap);
            wrap.PStockTacking.WcfEntityState = EntityState.Unchanged;
            if (wrap.PStockTackingDtl != null && wrap.PStockTackingDtl.Count > 0)
            {
                foreach (var c in wrap.PStockTackingDtl)
                {
                    c.WcfEntityState = EntityState.Unchanged;
                }
            }
        }

        public StockTackingWrap GetWrap(string wrapMasterID)
        {
            var sc = Factory.WmsServiceFactory.GetServiceClient();
            var wrap = sc.GetStockTackingWrap(wrapMasterID);
            wrap.PStockTacking.WcfEntityState = EntityState.Unchanged;
            wrap.PStockTacking.BindPropertyChanged();
            if (wrap.PStockTackingDtl != null && wrap.PStockTackingDtl.Count > 0)
            {
                foreach (var c in wrap.PStockTackingDtl)
                {
                    c.WcfEntityState = EntityState.Unchanged;
                    c.BindPropertyChanged();
                }
            }
            return wrap;
        }
    }
}
